home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / dev / amos / BSDSocket.readme < prev    next >
Text File  |  1998-05-05  |  4KB  |  128 lines

  1. Short:    Use bsdsocket.library calls in AmosPro
  2. Author:   uv334@victoria.tc.ca
  3. Uploader: uv334@victoria.tc.ca
  4. Type:     dev/amos
  5.  
  6. These procedures directly call bsdsocket.library, the TCP library created by
  7. your Internet Dialer (Miami, AmiTCP, TermiteTCP).  They are much faster and more
  8. friendly than the TCP: device equivalents, as they allow transfers to be
  9. Non-Blocking.  Normally, with TCP:, if there was no data to get, TCP: would lock
  10. until it got some.  Now, the program will simply ignore lack of data and move
  11. on.
  12.  
  13. You need a lot of memory to run a Stack and Amos at the same time.  I would say
  14. three or four meg would do it, depending on what else you have running.
  15.  
  16. Commands (port 80 is http):
  17.  
  18. BSD_OPEN
  19.   Open the bsdsocket.library
  20. BSD_CLOSE
  21.   Close the bsdsocket.library and all sockets attached
  22. SOCK_OPENCONNECTION[HOST$,SPORT]
  23.   Open a connection to a computer in the fashion tcp://HOST$:SPORT/
  24.   Returns Socket ID
  25.   Example: SOCK_OPENCONNECTION["www.yahoo.com",80]
  26. SOCK_OPENSERVER[SPORT]
  27.   Create a server port on your computer
  28.   Returns Socket ID
  29.   Example: SOCK_OPENSERVER[80]
  30. SOCK_CHECKHOSTPORT[SOCKET]
  31.   Check Host Socket for a connection
  32.   Returns Connected Socket ID (use this for transfers) or -1
  33.   Example: SOCK_CHECKHOSTPORT[MYPORT]
  34. SOCK_GETYOURHOST
  35.   Returns your host computer's name
  36.   Example: SOCK_GETYOURHOST : Print Param$
  37.            "as1s23-wmn.erols.com"
  38. SOCK_SENDSTRING[SOCKET,A$]
  39. SOCK_READSTRING[SOCKET,MXSIZE]
  40.   Writes and reads strings over a socket
  41.   SENDSTRING returns characters sent
  42.   READSTRING returns string received
  43. SOCK_SEND[SOCKET,ADR,LEN]
  44. SOCK_READ[SOCKET,ADR,LEN]
  45.   Send and receive large chunks of data over a socket
  46.   Both return numbers of characters sent/received
  47. SOCK_CLOSE[SOCKET]
  48.   Close a socket and save some memory
  49. SOCK_ERR[VARADDR]
  50.   Set a certain 4-byte memory address to receive TCP errors
  51. SOCK_NEW
  52.   Create a new socket
  53.   Returns socket ID of new socket
  54. SOCK_SETIO[SOCKET]
  55.   Set Non-Blocking, Asynchronous IO on a Socket
  56.  
  57. There are also a collection of commands especially for working with FTP, as it
  58. uses a crazy system of ports and data links.  I decided to save youall the
  59. trouble of figuring out FTP.  Grab the RFC for FTP.  With these commands, you'll
  60. have it all figured out.
  61.  
  62. FTP_OPENCONNECTION[HOST$,SPORT]
  63.   Open an FTP connection (ftp://HOST$:SPORT/)
  64. FTP_HOSTSOCK
  65.   Returns Socket ID of Host machine (where to send FTP commands)
  66. FTP_YOURSOCK
  67.   Returns your Socket ID for transfers (where to check for files)
  68. FTP_YOURPORT$
  69.   Returns the PORT string to use
  70. FTP_CLOSECONNECTION
  71.   Close FTP connections
  72.   
  73. 'A Sample TCP/FTP Session
  74. 'All the major commands are used in here
  75.  
  76. (FTP port is 23)
  77.  
  78. FTP_OPENCONNECTION["ftp.wustl.edu",23]
  79. Proc FTP_HOSTSOCK : HOSTSOCK=Param
  80. Proc FTP_YOURSOCK : YOURSOCK=Param
  81. Proc FTP_YOURPORT$ : YOURPORT$=Param$
  82.  
  83. E$=Chr$(13)+Chr$(10)
  84.  
  85. SOCK_SENDSTRING[HOSTSOCK,"USER anonymous"+E$]
  86. SOCK_SENDSTRING[HOSTSOCK,"PASS uv334@victoria.tc.ca"+E$]
  87. Repeat
  88.   SOCK_READSTRING[HOSTSOCK,256]
  89.   Print Param$
  90. Until Param$=""
  91.  
  92. SOCK_SENDSTRING[HOSTSOCK,"CD /pub/aminet/game/rpg/"+E$]
  93. SOCK_SENDSTRING[HOSTSOCK,YOURPORT$]
  94. Repeat
  95.   SOCK_READSTRING[HOSTSOCK,256]
  96.   Print Param$
  97. Until Param$=""
  98.  
  99. SOCK_SENDSTRING[HOSTSOCK,"GET FinalExistence.lha"] : Rem Shameless, aren't I?
  100. CONN=-1
  101. Repeat
  102.   SOCK_CHECKHOSTPORT[YOURSOCK]
  103.   If Param>-1
  104.     CONN=Param
  105.     Reserve As Work 23,2048
  106.     Open Out 1,"FinalExistence.lha"
  107.     Repeat
  108.       SOCK_READ[CONN,Start(23),2048] : BYTES=Param
  109.       If BYTES>-1
  110.         Ssave 1,Start(23) to Start(23)+BYTES-1
  111.       End If
  112.     Until BYTES=-1
  113.   End If
  114. Until CONN>-1
  115. SOCK_CLOSE[CONN]
  116.  
  117. FTP_CLOSECONNECTION
  118.  
  119.  
  120. ============================= Archive contents =============================
  121.  
  122. Original  Packed Ratio    Date     Time    Name
  123. -------- ------- ----- --------- --------  -------------
  124.     6648    2233 66.4% 28-Feb-98 08:21:54  BSDSocket.amos
  125.     3623    1607 55.6% 28-Feb-98 08:25:18  BSDSocket.readme
  126. -------- ------- ----- --------- --------
  127.    10271    3840 62.6% 09-Mar-98 13:08:26   2 files
  128.